package com.emenu;

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.RelativeLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TabWidget;
import android.widget.TextView;

public class MenuTab extends ActivityGroup {

	public static TabHost tab_host;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.bottomtab);

		tab_host = (TabHost) findViewById(R.id.edit_item_tab_host);
		final TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
		// 设置tabs的分割线颜色

		tabWidget.setBackgroundColor(android.R.color.white);

		tab_host.setup(this.getLocalActivityManager());

		TabSpec ts1 = tab_host.newTabSpec("TAB_operate");
		ts1.setIndicator("• 操作");
		ts1.setContent(new Intent(this, FragmentMAin.class));
		tab_host.addTab(ts1);

		TabSpec ts2 = tab_host.newTabSpec("TAB_function");
		ts2.setIndicator("• 功能");
		ts2.setContent(new Intent(this, FunctionLoginActive.class)
				.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
		tab_host.addTab(ts2);

		TabSpec ts3 = tab_host.newTabSpec("TAB_help");
		ts3.setIndicator("• 帮助");
		
		ts3.setContent(new Intent(this, EHelp.class));
		tab_host.addTab(ts3);

		tab_host.setCurrentTab(0);

		for (int i = 0; i < tabWidget.getChildCount(); i++) {
			tabWidget.getChildAt(i).getLayoutParams().height = 45;
			
			tabWidget.getChildAt(i).setBackgroundResource(R.color.tagsbgcolor);// 设置背景
			
			/**
			 * 设置tab中标题文字的颜色，不然默认为黑色
			 */
			final TextView tv = (TextView) tabWidget.getChildAt(i)
					.findViewById(android.R.id.title);
			tv.setTextSize(20);
			tv.setTextColor(this.getResources().getColorStateList(
					android.R.color.white));
			
			 RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) tv.getLayoutParams();
             params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); //取消文字底边对齐
             params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); //设置文字居中对齐

		 
			

		}

	}

}
